//
//  AddStaffChooseGenderCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2020/8/31.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "AddStaffChooseGenderCell.h"

@interface AddStaffChooseGenderCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIButton *normalBtn;
@property (nonatomic, strong) UIButton *stopBtn;
@property (nonatomic, strong) UILabel *lineLab;

@end

@implementation AddStaffChooseGenderCell

+ (instancetype)AddStaffChooseGenderCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"AddStaffChooseGenderCell";
    AddStaffChooseGenderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[AddStaffChooseGenderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 60)];
        self.bgView.backgroundColor = HexColor(0xffffff);
//        self.bgView.layer.masksToBounds = YES;
//        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        UILabel *lab = [UILabel new];
        lab.text = @"性别";
        lab.textColor = HexColor(0x2B2C44);
        lab.font = [UIFont systemFontOfSize:16];
        [lab sizeToFit];
        lab.nim_left = 15;
        lab.nim_centerY = self.bgView.nim_height * 0.5;
        [self.bgView addSubview:lab];
        
        UIView *btnBGView = [[UIView alloc] initWithFrame:CGRectMake(self.bgView.nim_width - 10 - 96, 9, 96, 32)];
        btnBGView.backgroundColor = Color_backgroundColor;
        btnBGView.layer.masksToBounds = YES;
        btnBGView.layer.cornerRadius = 16;
        btnBGView.nim_centerY = lab.nim_centerY;
        [self.bgView addSubview:btnBGView];
        
        self.normalBtn = [[UIButton alloc] initWithFrame:CGRectMake(4, 4, 44, 24)];
        self.normalBtn.backgroundColor = Color_ThemeColor;
        self.normalBtn.layer.masksToBounds = YES;
        self.normalBtn.layer.cornerRadius = 12;
        [self.normalBtn setTitle:@"男" forState:0];
        [self.normalBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.normalBtn.titleLabel.font = BoldFontOfSize(12);
        [self.normalBtn addTarget:self action:@selector(changeClick) forControlEvents:UIControlEventTouchUpInside];
        [btnBGView addSubview:self.normalBtn];
        
        self.stopBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.normalBtn.nim_right, 4, 44, 24)];
        self.stopBtn.backgroundColor = Color_backgroundColor;
        self.stopBtn.layer.masksToBounds = YES;
        self.stopBtn.layer.cornerRadius = 12;
        [self.stopBtn setTitle:@"女" forState:0];
        [self.stopBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        self.stopBtn.titleLabel.font = BoldFontOfSize(12);
        [self.stopBtn addTarget:self action:@selector(changeClick) forControlEvents:UIControlEventTouchUpInside];
        [btnBGView addSubview:self.stopBtn];
        
        self.lineLab = [[UILabel alloc] initWithFrame:CGRectMake(10, self.bgView.nim_height - 1, self.bgView.nim_width - 20, 1)];
        self.lineLab.backgroundColor = Color_backgroundColor;
        [self.bgView addSubview:self.lineLab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setIsMan:(BOOL)isMan {
    _isMan = isMan;
    if (isMan) {
        //男
        self.normalBtn.backgroundColor = Color_ThemeColor;
        [self.normalBtn setTitleColor:HexColor(0xffffff) forState:0];
        
        self.stopBtn.backgroundColor = Color_backgroundColor;
        [self.stopBtn setTitleColor:HexColor(0x2B2C44) forState:0];
    }else {
        //女
        self.normalBtn.backgroundColor = Color_backgroundColor;
        [self.normalBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        
        self.stopBtn.backgroundColor = HexColor(0xF35959);
        [self.stopBtn setTitleColor:HexColor(0xffffff) forState:0];
    }
}

- (void)changeClick {
    if (self.changeBlock) {
        self.changeBlock();
    }
}

-(void)setShowLine:(BOOL)showLine {
    _showLine = showLine;
    self.lineLab.hidden = !showLine;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
